﻿using System;
using ZX.Common;
using ZX.DBModule;
using ZX.Web.UI.Controls;
using ZX.BLL.Extend;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using ZX.Common.Extend;
using ZX.EHR.Library;

namespace ZX.WebApp.TR
{
    public partial class DateLook : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string wpid = Request.QueryString["DPID"];
            if (!this.IsPostBack)
            {
                bangdata(wpid);
            }
        }
        protected void bangdata(string wpid)
        {

            if (wpid != "")
            {
                hdfdpid.Value = wpid;
                ZX.TR.Library.TrDatePlan tdp = new ZX.TR.Library.TrDatePlan();
                BaseBussnies bbp = new BaseBussnies(tdp);
                IList<ZX.TR.Library.V_TrDatePlan> tdpl = bbp.GetEntitys<ZX.TR.Library.V_TrDatePlan>("TrDatePlanID='" + wpid + "'");
                if (tdpl != null)
                {
                    LabDateR.Text = tdpl[0].WriteDate.ToShortDateString();
                    LabDateP.Text = tdpl[0].WriteDate.ToShortDateString();
                    LabName.Text = tdpl[0].UName;
                    TaDateShare.Value = tdpl[0].DateShare;
                    TaWarpMend.Value = tdpl[0].WarpMend;
                    TaSelfUp.Value = tdpl[0].SelfUp;
                    TaNowPoint.Value = tdpl[0].NowPoint;

                    bangWork(tdpl[0].TrDatePlanID);
                    BandCheck(tdpl[0].TrDatePlanID);
                }
            }
        }

        //绑定工作项
        protected void bangWork(Guid gr)
        {
            ZX.TR.Library.TrDateWork tdw = new ZX.TR.Library.TrDateWork();
            BaseBussnies bbw = new BaseBussnies(tdw);
            IList<ZX.TR.Library.V_TrDateWork> tdwlr = bbw.GetEntitys<ZX.TR.Library.V_TrDateWork>("TrDatePlanID='" + gr + "'");
            if (tdwlr != null)
            {
                if (tdwlr[0].WorkType == "S")
                {
                    hdfdrw1.Value = tdwlr[0].TrDateWorkID.ToString();
                    Ta11.Value = tdwlr[0].WorkContent;
                    Ta12.Value = tdwlr[0].InfactResult;
                    Ta13.Value = tdwlr[0].DoneCase;
                    Ta14.Value = tdwlr[0].SelfCase;
                    Ta31.Value = tdwlr[0].WorkContent;
                    Ta32.Value = tdwlr[0].PreResult;
                    //hdf33.Value = tdwlr[0].Checker.ToString();
                    //Ta33.Value = tdwlr[0].checkername.ToString();
                    Ta34.Value = tdwlr[0].PlanSelf;

                    hdfdrw2.Value = tdwlr[1].TrDateWorkID.ToString();
                    Ta21.Value = tdwlr[1].WorkContent;
                    Ta22.Value = tdwlr[1].InfactResult;
                    Ta23.Value = tdwlr[1].DoneCase;
                    Ta24.Value = tdwlr[1].SelfCase;

                    Ta41.Value = tdwlr[1].WorkContent;
                    Ta42.Value = tdwlr[1].PreResult;
                    //hdf43.Value = tdwlr[1].Checker.ToString();
                    //Ta43.Value = tdwlr[1].checkername.ToString();
                    Ta44.Value = tdwlr[1].PlanSelf;
                }
                else
                {
                    hdfdrw1.Value = tdwlr[1].TrDateWorkID.ToString();
                    Ta11.Value = tdwlr[1].WorkContent;
                    Ta12.Value = tdwlr[1].InfactResult;
                    Ta13.Value = tdwlr[1].DoneCase;
                    Ta14.Value = tdwlr[1].SelfCase;

                    hdfdrw2.Value = tdwlr[0].TrDateWorkID.ToString();
                    Ta21.Value = tdwlr[0].WorkContent;
                    Ta22.Value = tdwlr[0].InfactResult;
                    Ta23.Value = tdwlr[0].DoneCase;
                    Ta24.Value = tdwlr[0].SelfCase;

                    Ta41.Value = tdwlr[0].WorkContent;
                    Ta42.Value = tdwlr[0].PreResult;
                    //hdf43.Value = tdwlr[0].Checker.ToString();
                    //Ta43.Value = tdwlr[0].checkername.ToString();
                    Ta44.Value = tdwlr[0].PlanSelf;

                    Ta31.Value = tdwlr[1].WorkContent;
                    Ta32.Value = tdwlr[1].PreResult;
                    //hdf33.Value = tdwlr[1].Checker.ToString();
                    //Ta33.Value = tdwlr[1].checkername.ToString();
                    Ta34.Value = tdwlr[1].PlanSelf;
                }
            }

        }

        protected void BandCheck(Guid gr)
        {
            ZX.TR.Library.V_TrDateCheck tdc = new ZX.TR.Library.V_TrDateCheck();
            BaseBussnies bbw = new BaseBussnies(tdc);
            IList<ZX.TR.Library.V_TrDateCheck> tdclr = bbw.GetEntitys<ZX.TR.Library.V_TrDateCheck>("TrDatePlanID='" + gr + "'");
            if (tdclr != null)
            {
                rptCheck.DataSource = tdclr;
                rptCheck.DataBind();
            }

        }

    }
}